#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# ======================================================
# @File:      : test49
# @Author     : forward_huan
# @Date       : 2024/11/16 17:15
# @Desc       :
# ======================================================
from typing import List


class Solution:
    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        data = {}
        for item in strs:
            s_item = "".join(sorted(item))
            if s_item not in data:
                data[s_item] = [item]
            else:
                data[s_item].append(item)
        return list(data.values())


print(Solution().groupAnagrams(strs = ["eat", "tea", "tan", "ate", "nat", "bat"]))